#include <httplib.h>
#include <fstream>
#include <iostream>
#include <string>

class TESTHTTP
{
   private:
    httplib::Client *m_cli;

   public:
    TESTHTTP()
    {
        m_cli = new httplib::Client("https://localhost:8887");
    }
    ~TESTHTTP()
    {
        delete m_cli;
    }

    void testGetHello();
};

void TESTHTTP::testGetHello()
{
    httplib::Params params = {{"params", "test"}};
    httplib::Headers headers = {{"version", "0.0.0.1"},
                                {"token", "V66n56XJBD/4LTMsGDqE0dlRPtkVmQ0hlIQNwcBMZkU4bQeDTBlMEUluqnha1g/ZsEMK/0JHKtEBwHH2Ko9iEA=="}};
    auto res = m_cli->Get("/dd/hello", params, headers);
    std::cout << httplib::to_string(res.error()) << std::endl;
    std::cout << res->body << std::endl;
}

class TESTHTTPS
{
   private:
    httplib::Client *m_cli;

   public:
    TESTHTTPS()
    {
        m_cli = new httplib::Client("https://localhost:8887");
        m_cli->set_ca_cert_path("./data/cacert.pem");
        m_cli->enable_server_certificate_verification(true);
    }
    ~TESTHTTPS()
    {
        delete m_cli;
    }

    void testGetHello();
};

void TESTHTTPS::testGetHello()
{
    httplib::Params params = {{"params", "test"}};
    httplib::Headers headers = {{"version", "0.0.0.1"},
                                {"token", "V66n56XJBD/4LTMsGDqE0dlRPtkVmQ0hlIQNwcBMZkU4bQeDTBlMEUluqnha1g/ZsEMK/0JHKtEBwHH2Ko9iEA=="}};
    auto res = m_cli->Get("/dd/hello", params, headers);
    std::cout << httplib::to_string(res.error()) << std::endl;
    std::cout << res->body << std::endl;
}

int main(void)
{
    // TESTHTTP T;
    // T.testPostPush();

    TESTHTTPS T;
    T.testGetHello();
}
